<?php use_javascripts_for_form($form) ?>
<div id="form">
    <!-- Back button -->
    <a href="<?php echo url_for('stock_index') ?>" class="bt_back"><img src="<?php echo image_path('Buttons/bt_arrow_back.png') ?>" onmouseover="this.src='<?php echo image_path('Buttons/bt_arrow_back_hov.png') ?>'" onmouseout="this.src='<?php echo image_path('Buttons/bt_arrow_back.png') ?>'"></a>
    
    <form action="<?php echo url_for('stock/updatePart?id='.$form->getObject()->getId()) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
        <?php if (!$form->getObject()->isNew()): ?>
            <input type="hidden" name="sf_method" value="put" />
        <?php endif; ?>
            <?php $material = $form->getObject() ?>
        <fieldset> <!-- Material information area -->
            <legend class="bold">General Information</legend>
            <table> 
                <tr>
                    <td class="bold" style="width: 100px;">Name:</td>
                    <td><?php echo $material->getName() ?></td>
                    <td class="bold" style="width: 70px;">Type:</td>
                    <td><?php echo $material->getType() ?></td>
                </tr>
                <tr>
                    <td class="bold">Material No.:</td>
                    <td><?php echo $material->getPartNumber() ?></td>
                </tr>
            </table>
        </fieldset>
        <fieldset> <!-- Put material in production area -->
            <legend class="bold">Enter Production</legend>
            <table>
                <tr>
                    <td class="left_title">Order No.:</td>
                    <td><input type="text" name="orderno" size="6"/></td>
                </tr>
                <tr>
                    <td class="left_title">Quantity used:</td>
                    <td><input type="text" name="production" size="6"/></td>
                </tr>
                <tr> <!-- Check if an error message has to be shown, given from the action -->
                    <?php if ($emptyMsg == true){ ?>
                <p style="color: red;"> The entered order number does not exist </p>
                <?php }else if ($materialMsg == true){ ?>
                <p style="color: red;"> Entered order cannot be altered anymore</p>
                <?php } ?>
                </tr>
            </table>
        </fieldset>
        <input type="submit" value="" class="ok"/>
        <div class="hidden_csrf"><?php echo $form['stock']->renderRow(); ?></div>
        <div class="hidden_csrf"><?php echo $form['location']->renderRow(); ?></div>
        <div class="hidden_csrf"><?php echo $form['min_stock']->renderRow(); ?></div>
        <div class="hidden_csrf"><?php echo $form['_csrf_token']->renderRow(); ?></div>
        <div class="hidden_csrf"><?php echo $form['part_number']->renderRow(); ?></div>
        <div class="hidden_csrf"><?php echo $form['name']->renderRow(); ?></div>
        <div class="hidden_csrf"><?php echo $form['VAT']->renderRow(); ?></div>
        <div class="hidden_csrf"><?php echo $form['type']->renderRow(); ?></div>
        <div class="hidden_csrf"><?php echo $form['description']->renderRow(); ?></div>
        <div class="hidden_csrf"><?php echo $form['reserved']->renderRow(); ?></div>
        <div class="hidden_csrf"><?php echo $form['in_production']->renderRow(); ?></div>
        <div class="hidden_csrf"><?php echo $form['ordered']->renderRow(); ?></div>       

    </form>
</div>
